<?php
class Cliente extends Doctrine_Record {
    public function setTableDefinition() {
        $this->setTableName('cliente');
        $this->hasColumn('razon', 'string', 255);
        $this->hasColumn('cuit', 'integer', 14);
        $this->hasColumn('dni', 'integer', 14);
    }
    
    public static function test () {
        return 'Anda';
    }
    
    //FUNCIONES DE PAGINADO    
    public static function contar() {     
        $q = Doctrine_Query::create()
            ->select('count(c.id) as total')
            ->from('Cliente c');
        $total = $q->execute();
        return ($total->count())?$total[0]->total:0;
    }

    public static function listar($parametros) {
        $defualt = array('cuantos'=>99999, 'desde'=>0);
        $options = $parametros + $defualt;        
        $q = Doctrine_Query::create()
            ->select('c.*')
            ->from('Cliente c')
            ->limit($options['cuantos'])
            ->offset($options['desde'])
            ->orderBy('c.razon');
        $resultado = $q->execute();
        return $resultado;
    }
}
?>